<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/commons/pages/taglibs.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>为用户分配DTU</title>
<link rel="stylesheet" type="text/css" href="../jquery-easyui/themes/${themes}/easyui.css">
<link rel="stylesheet" type="text/css" href="../jquery-easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="../styles/demo.css">
<script type="text/javascript" src="../jquery-easyui/jquery.min.js"></script>
<script type="text/javascript" src="../jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../jquery-easyui/plugins/jquery.validatebox.rules.js"></script>
<script type="text/javascript" src="../scripts/public.js.jsp"></script>
<script type="text/javascript" src="${ctx}/platform/type-info/format"></script>
</head>
<body>
<!--div class="demo-info">
  <div class="demo-tip icon-tip"></div>
  <div>为用户分配DTU</div>
</div-->
<c:if test="${true}">
  <div style="padding:5px; margin-bottom:5px; display:block;" class="combo">
    <form method="post" id="fm_search" novalidate style="display:inline-block">
      用户：
        <select id="user_id" name="user_id" style="width:80px;">
      </select>
      DTU ID：
      <select id="modem_id" name="modem_id" style="width:80px;">
      </select>
      删除：
      <select id="is_del" name="is_del" style="width:50px;">
      </select>
      <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="doSearch();">搜索</a> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="$('#fm_search').form('clear');">重置</a>
    </form>
  </div>
</c:if>
<div id="dg"> </div>
<div id="dlg" class="easyui-dialog" data-options="closed:true, modal:true, buttons:'#dlg-buttons'" style="width:400px; height:240px; padding:10px 40px">
  <form method="post" id="fm" novalidate>
    <input name="id" type="hidden" id="id" />
    <table>
      <tr>
        <td align="right" width="160"><b>用户名：</b></td>
        <td width="240"><select id="user_id" name="user_id" class="easyui-validatebox" style="width:120px;" data-options="required:true">
          </select></td>
      </tr>
      <tr>
        <td align="right"><b>DTU ID：</b></td>
        <td><input name="modem_id" id="modem_id" type="text" style="width:77px;" size="8" maxlength="8" class="easyui-numberbox" data-options="required:true,validType:'minLength[8]'" /></td>
      </tr>
      <tr>
        <td align="right"><b>删除：</b></td>
        <td><select id="is_del" name="is_del" style="width:80px;" class="easyui-validatebox" data-options="required:true, editable:false">
          </select></td>
      </tr>
    </table>
  </form>
</div>
<div id="dlg-buttons"> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="doSave();">保存</a> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#dlg').dialog('close');">关闭</a> </div>
<script type="text/javascript">
$(function(){
	$("select[id='user_id']").each(function(i){ //删除
		$(this).combobox({
			onLoadSuccess: function(data){
				//
			}
		}).combobox({
			panelHeight: "auto",
			editable: false,
			url: ctx + '/platform/user-info/json',
		    valueField: 'id',  
		    textField: 'user_name'
		})
	});
	
	//初始化列表
	$('#dg').datagrid({  
	    url:'${ctx}/platform/user-dtu/search',
		queryParams:$('#fm_search').serializeObject(),
	    frozenColumns:[[
	    	{field:'ck',checkbox:true}
	 	]],
	    columns:[[
			//{field:'id',title:'id',hidden:true},   
	        {width:100,  align:'left' , field:'map', title:'用户名称',formatter:function(value){
	        	return value.user_name;
	        }},
	        {width:100, align:'center', field:'modem_id', title:'DTU ID', sortable:true},
	        {width:200, align:'center', field:'create_time', title:'分配时间',formatter:formatDateTime},
			{width:40, field:'is_del',title:'删除',align:'center',formatter:formatBoolean, styler:styleBoolean}
	    ]],
		//fitColumns:true,
		striped:true,
		pagination:true,
		remoteSort:false,
		rownumbers:true,
		singleSelect:false,
		autoSizeColumn:true,
		toolbar:[
			//<c:if test="${true}">
			{
				id:'btnRemove',
				text:'删除',
				iconCls:'icon-remove',
				handler:function(){doRemove();}
			},'-',
			//</c:if>
			//<c:if test="${true}">
			{
				id:'btnAdd',
				text:'添加',
				iconCls:'icon-add',
				handler:function(){doAdd();}
			},
			//</c:if>
			//<c:if test="${true}">
			{
				id:'btnEdit',
				text:'修改',
				iconCls:'icon-edit',
				handler:function(){doEdit();}
			},
			//</c:if>{}
		] 
	}); 
}); 
</script>
</body>
</html>